inherited crdAddDogovor2Acc: TcrdAddDogovor2Acc
  Left = 338
  Top = 337
  Width = 755
  Height = 517
  BorderIcons = [biSystemMenu, biMinimize, biMaximize, biHelp]
  Caption = #1055#1086#1076#1082#1083#1102#1095#1077#1085#1080#1077' '#1076#1086#1075#1086#1074#1086#1088#1072' '#1082' '#1090#1086#1095#1082#1077' '#1080#1085#1089#1090#1088#1091#1084#1077#1085#1090#1072#1083#1100#1085#1086#1075#1086' '#1091#1095#1077#1090#1072
  OldCreateOrder = True
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  inherited Panel1: TPanel
    Top = 463
    Width = 747
    TabOrder = 3
    inherited BitBtn1: TBitBtn
      Left = 548
      Caption = #1055#1086#1076#1082#1083#1102#1095#1080#1090#1100
    end
    inherited BitBtn2: TBitBtn
      Left = 649
    end
  end
  inherited ToolBar1: TToolBar
    Width = 747
    Height = 0
    TabOrder = 2
  end
  object Panel2: TPanel [2]
    Left = 485
    Top = 0
    Width = 262
    Height = 463
    Align = alRight
    BevelInner = bvRaised
    BevelOuter = bvLowered
    TabOrder = 0
    inline fraAddress: TfraAddress
      Left = 2
      Top = 92
      Width = 258
      Height = 205
      Align = alTop
      TabOrder = 2
      inherited SearchBox: TGroupBox
        Height = 205
        inherited SubPanel: TPanel
          Height = 188
          inherited FindBtn: TButton
            Left = 50
            Top = 155
            Caption = #1055#1086#1080#1089#1082
            OnClick = fraAddress1FindBtnClick
          end
          inherited ClearBtn: TButton
            Left = 144
            Top = 155
          end
          inherited AddBtn: TButton
            Left = 256
            Top = 200
            Width = 7
            Visible = False
          end
        end
      end
      inherited QStreets: TpFIBDataSet
        Transaction = LocalTrans
        Database = MAINDM.pMainDatabase
        UpdateTransaction = LocalTrans
      end
      inherited QHouses: TpFIBDataSet
        Transaction = LocalTrans
        Database = MAINDM.pMainDatabase
        UpdateTransaction = LocalTrans
      end
      inherited QTowns: TpFIBDataSet
        Transaction = LocalTrans
        Database = MAINDM.pMainDatabase
        UpdateTransaction = LocalTrans
      end
      inherited QApparts: TpFIBDataSet
        Transaction = LocalTrans
        UpdateTransaction = LocalTrans
      end
    end
    object GroupBox1: TGroupBox
      Left = 2
      Top = 47
      Width = 258
      Height = 45
      Align = alTop
      Caption = ' '#1044#1072#1090#1072' '#1087#1086#1076#1082#1083#1102#1095#1077#1085#1080#1103' '
      TabOrder = 1
      object dbtBdate: TDBDateTimeEditEh
        Left = 11
        Top = 17
        Width = 240
        Height = 19
        AlwaysShowBorder = True
        EditButtons = <>
        Flat = True
        Kind = dtkDateEh
        TabOrder = 0
        Visible = True
      end
    end
    object GroupBox2: TGroupBox
      Left = 2
      Top = 2
      Width = 258
      Height = 45
      Align = alTop
      Caption = ' '#1042#1099#1073#1086#1088' '#1091#1089#1083#1091#1075#1080' '
      TabOrder = 0
      object lcbSrvGroup: TDBLookupComboboxEh
        Left = 11
        Top = 17
        Width = 240
        Height = 19
        AlwaysShowBorder = True
        DropDownBox.SpecRow.CellsText = '---'
        DropDownBox.SpecRow.Value = -1
        DropDownBox.SpecRow.Visible = True
        EditButtons = <>
        Flat = True
        KeyField = 'ID'
        ListField = 'NAME'
        ListSource = dsc_SrvGroup
        TabOrder = 0
        Visible = True
      end
    end
  end
  object PageControl: TPageControl [3]
    Left = 0
    Top = 0
    Width = 485
    Height = 463
    ActivePage = tsDogovorList
    Align = alClient
    Style = tsFlatButtons
    TabOrder = 1
    object tsDogovorList: TTabSheet
      Caption = #1056#1077#1079#1091#1083#1100#1090#1072#1090#1099' '#1087#1086#1080#1089#1082#1072
      object dbgDogovors: TDBGridEh
        Left = 0
        Top = 0
        Width = 477
        Height = 432
        Hint = '(Ctrl + A) '#1042#1099#1076#1077#1083#1080#1090#1100' '#1074#1089#1077
        Align = alClient
        DataGrouping.GroupLevels = <>
        DataSource = dsc_Dogovors
        Flat = True
        FooterColor = clWindow
        FooterFont.Charset = DEFAULT_CHARSET
        FooterFont.Color = clWindowText
        FooterFont.Height = -11
        FooterFont.Name = 'MS Sans Serif'
        FooterFont.Style = []
        Options = [dgTitles, dgColumnResize, dgColLines, dgRowLines, dgRowSelect, dgConfirmDelete, dgCancelOnExit, dgMultiSelect]
        OptionsEh = [dghFixed3D, dghHighlightFocus, dghClearSelection, dghAutoSortMarking, dghMultiSortMarking, dghDblClickOptimizeColWidth, dghDialogFind, dghColumnResize, dghColumnMove]
        ParentShowHint = False
        RowDetailPanel.Color = clBtnFace
        ShowHint = True
        SortLocal = True
        TabOrder = 0
        TitleFont.Charset = DEFAULT_CHARSET
        TitleFont.Color = clWindowText
        TitleFont.Height = -11
        TitleFont.Name = 'MS Sans Serif'
        TitleFont.Style = []
        UseMultiTitle = True
        VTitleMargin = 5
        OnKeyUp = dbgDogovorsKeyUp
        OnSortMarkingChanged = dbgDogovorsSortMarkingChanged
        Columns = <
          item
            EditButtons = <>
            FieldName = 'ADDRESS'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'SERVICE_NAME'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'ABON_NAME'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'METER_EXIST'
            Footers = <>
            KeyList.Strings = (
              '1'
              '0')
            PickList.Strings = (
              #1059#1089#1090#1072#1085#1086#1074#1083#1077#1085
              #1054#1090#1089#1091#1090#1089#1090#1074#1091#1077#1090)
          end
          item
            EditButtons = <>
            FieldName = 'ACCPOINT_ID'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'ABONENT_ID'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'DOGOVOR_ID'
            Footers = <>
          end>
        object RowDetailData: TRowDetailPanelControlEh
        end
      end
    end
    object tsAppendLog: TTabSheet
      Caption = #1054#1096#1080#1073#1082#1080' '#1087#1086#1076#1082#1083#1102#1095#1077#1085#1080#1103
      ImageIndex = 1
      TabVisible = False
      object dbgAppendLog: TDBGridEh
        Left = 0
        Top = 0
        Width = 477
        Height = 432
        Align = alClient
        DataGrouping.GroupLevels = <>
        DataSource = dsc_Append
        Flat = True
        FooterColor = clWindow
        FooterFont.Charset = DEFAULT_CHARSET
        FooterFont.Color = clWindowText
        FooterFont.Height = -11
        FooterFont.Name = 'MS Sans Serif'
        FooterFont.Style = []
        Options = [dgTitles, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect, dgConfirmDelete, dgCancelOnExit, dgMultiSelect]
        OptionsEh = [dghFixed3D, dghHighlightFocus, dghClearSelection, dghDblClickOptimizeColWidth, dghDialogFind, dghColumnResize, dghColumnMove]
        PopupMenu = pmAppend
        RowDetailPanel.Color = clBtnFace
        TabOrder = 0
        TitleFont.Charset = DEFAULT_CHARSET
        TitleFont.Color = clWindowText
        TitleFont.Height = -11
        TitleFont.Name = 'MS Sans Serif'
        TitleFont.Style = []
        UseMultiTitle = True
        VTitleMargin = 5
        Columns = <
          item
            EditButtons = <>
            FieldName = 'RACCPOINT_ID'
            Footers = <>
          end
          item
            EditButtons = <>
            FieldName = 'RMESSAGE'
            Footers = <>
          end>
        object RowDetailData: TRowDetailPanelControlEh
        end
      end
    end
  end
  inherited ActionList1: TActionList
    Left = 461
    Top = 257
    inherited aSave: TAction
      Caption = #1055#1086#1076#1082#1083#1102#1095#1080#1090#1100
      Hint = #1055#1086#1076#1082#1083#1102#1095#1080#1090#1100' '#1076#1086#1075#1086#1074#1086#1088#1072' '#1082' '#1058#1059
      OnExecute = aSaveExecute
    end
    inherited aCancel: TAction
      Hint = #1054#1090#1084#1077#1085#1080#1090#1100' '#1080#1079#1084#1077#1085#1077#1085#1080#1103' '#1080' '#1074#1099#1081#1090#1080
      OnExecute = aCancelExecute
    end
  end
  inherited PropStorage: TPropStorageEh
    Section = 'crdAddDogovor2Acc'
    StoredProps.Strings = (
      '<P>.Height'
      '<P>.Left'
      '<P>.PixelsPerInch'
      '<P>.Top'
      '<P>.Width'
      'PageControl.tsAppendLog.dbgAppendLog.<P>.Columns.ColumnsIndex'
      
        'PageControl.tsAppendLog.dbgAppendLog.<P>.Columns.<ForAllItems>.W' +
        'idth'
      'PageControl.tsDogovorList.dbgDogovors.<P>.Columns.ColumnsIndex'
      
        'PageControl.tsDogovorList.dbgDogovors.<P>.Columns.<ForAllItems>.' +
        'Width')
    Left = 427
    Top = 257
  end
  object ds_SrvGroup: TpFIBDataSet
    SelectSQL.Strings = (
      'select s.id, s.name from services s'
      '  where s.group_id = 0'
      '    and exists (select 1 from dogovors ds, services ss'
      '          where ds.service_id = ss.id and ss.group_id = s.id'
      '            and ds.is_active = 1)'
      '    and exists (select 1 from vw_straits vw'
      '          where vw.code = '#39'CAN_METER'#39' and vw.service_id = s.id)'
      '  order by 2')
    Transaction = LocalTrans
    Database = MAINDM.pMainDatabase
    Left = 550
    Top = 12
    object ds_SrvGroupID: TFIBIntegerField
      FieldName = 'ID'
    end
    object ds_SrvGroupNAME: TFIBStringField
      FieldName = 'NAME'
      Size = 120
      EmptyStrToNull = True
    end
  end
  object dsc_SrvGroup: TDataSource
    DataSet = ds_SrvGroup
    Left = 582
    Top = 12
  end
  object ds_Dogovors: TpFIBDataSet
    SelectSQL.Strings = (
      
        'select dogovor_id, accpoint_id, abonent_id, service_name, abon_n' +
        'ame, meter_exist, cast(house_address||list(appart, '#39','#39') as varch' +
        'ar(255)) as address'
      'from'
      '  (select'
      '      d.id,'
      
        '      (select first(1) pp.raccpoint_id from proc_accpoint_get_pa' +
        'rents(d.accpoint_id, :pdate, :pdate) pp order by pp.rlevel desc)' +
        ','
      '      rabon_id,'
      
        '      rtown||'#39', '#39'||rstreet_name||'#39' '#1076'.'#39'||rhouse||coalesce('#39' '#1082'.'#39'||' +
        'rcorps, '#39#39') as addr,'
      
        '      coalesce('#39' '#1082#1074'.'#39'||rapparts, '#39#39')||coalesce('#39'('#39'||rletter||'#39')'#39 +
        ', '#39#39'),'
      '      sg.name,'
      '      rname,'
      
        '      (case when exists (select 1 from proc_accpoint_meter_exist' +
        ' (d.accpoint_id, :pbdate) where rmeter_exist = 1)'
      '        then '#39#1059#1089#1090#1072#1085#1086#1074#1083#1077#1085#39' else '#39#1054#1090#1089#1091#1090#1089#1090#1074#1091#1077#1090#39' end) as meter_exist'
      '  from'
      '      proc_v_abonents(:pnsl,'
      '      :ptown_id,'
      '      :pstreet_id,'
      '      :phouse,'
      '      :papparts,'
      '      :pname,'
      '      :pactive,'
      '      :pcorps,'
      '      :pletter,'
      '      :padd_params) p'
      
        '  join dogovors d on d.abonent_id = p.rabon_id and d.is_active =' +
        ' 1'
      
        '  and not exists (select 1 from proc_accpoint_get_parents (d.acc' +
        'point_id, :pbdate, current_date) pp, m_accpoint ma, m_accpoint_t' +
        'ype mt'
      
        '                where rlevel > 0 and ma.id = pp.raccpoint_id and' +
        ' mt.id = ma.account_type and mt.group_acc = 1)'
      '  join services s on s.id = d.service_id'
      '  join services sg on sg.id = s.group_id '
      '    and sg.id = :pgroup_id'
      
        '  order by addr, rapparts) as v (dogovor_id, accpoint_id, abonen' +
        't_id, house_address, appart, service_name, abon_name, meter_exis' +
        't)'
      
        '  group by dogovor_id, accpoint_id, abonent_id, service_name, ab' +
        'on_name, meter_exist, house_address')
    Transaction = LocalTrans
    Database = MAINDM.pMainDatabase
    Left = 62
    Top = 127
    object ds_DogovorsID: TFIBIntegerField
      DisplayLabel = #1048#1044' '#1076#1086#1075#1086#1074#1086#1088#1072
      FieldName = 'DOGOVOR_ID'
    end
    object ds_DogovorsRABON_ID: TFIBIntegerField
      FieldName = 'ABONENT_ID'
      Visible = False
    end
    object ds_DogovorsADDRESS: TFIBStringField
      DisplayLabel = #1040#1076#1088#1077#1089
      DisplayWidth = 30
      FieldName = 'ADDRESS'
      Size = 255
      EmptyStrToNull = True
    end
    object ds_DogovorsSERVICE: TFIBStringField
      DisplayLabel = #1059#1089#1083#1091#1075#1072
      DisplayWidth = 20
      FieldName = 'SERVICE_NAME'
      Size = 120
      EmptyStrToNull = True
    end
    object ds_DogovorsRNAME: TFIBStringField
      FieldName = 'ABON_NAME'
      Visible = False
      Size = 92
      EmptyStrToNull = True
    end
    object ds_DogovorsMETER_EXIST: TFIBStringField
      DisplayLabel = #1053#1072#1083#1080#1095#1080#1077' '#1089#1095#1077#1090#1095#1080#1082#1072
      DisplayWidth = 12
      FieldName = 'METER_EXIST'
      Size = 11
      EmptyStrToNull = True
    end
    object ds_DogovorsACCPOINT_ID: TFIBIntegerField
      DisplayLabel = #1048#1044' '#1058#1059
      FieldName = 'ACCPOINT_ID'
    end
  end
  object dsc_Dogovors: TDataSource
    DataSet = dsm_Dogovors
    Left = 162
    Top = 127
  end
  object LocalTrans: TpFIBTransaction
    DefaultDatabase = MAINDM.pMainDatabase
    TimeoutAction = TARollback
    Left = 380
    Top = 8
  end
  object dsc_Append: TDataSource
    DataSet = dsm_Append
    Left = 162
    Top = 160
  end
  object dsm_Dogovors: TMemTableEh
    FieldDefs = <
      item
        Name = 'DOGOVOR_ID'
        DataType = ftInteger
      end
      item
        Name = 'ABONENT_ID'
        DataType = ftInteger
      end
      item
        Name = 'ADDRESS'
        DataType = ftString
        Size = 255
      end
      item
        Name = 'SERVICE_NAME'
        DataType = ftString
        Size = 120
      end
      item
        Name = 'ABON_NAME'
        DataType = ftString
        Size = 92
      end
      item
        Name = 'METER_EXIST'
        DataType = ftString
        Size = 11
      end
      item
        Name = 'ACCPOINT_ID'
        DataType = ftInteger
      end>
    IndexDefs = <>
    Params = <>
    StoreDefs = True
    Left = 128
    Top = 127
    object dsm_DogovorsDOGOVOR_ID: TIntegerField
      DisplayLabel = #1048#1044' '#1076#1086#1075#1086#1074#1086#1088#1072
      FieldName = 'DOGOVOR_ID'
    end
    object dsm_DogovorsABONENT_ID: TIntegerField
      DisplayLabel = #1048#1044' '#1072#1073#1086#1085#1077#1085#1090#1072
      FieldName = 'ABONENT_ID'
    end
    object dsm_DogovorsADDRESS: TStringField
      DisplayLabel = #1040#1076#1088#1077#1089' '#1058#1059
      DisplayWidth = 25
      FieldName = 'ADDRESS'
      Size = 255
    end
    object dsm_DogovorsSERVICE_NAME: TStringField
      DisplayLabel = #1059#1089#1083#1091#1075#1072
      DisplayWidth = 20
      FieldName = 'SERVICE_NAME'
      Size = 120
    end
    object dsm_DogovorsABON_NAME: TStringField
      DisplayLabel = #1050#1074#1072#1088#1090#1080#1088#1086#1089#1098#1077#1084#1097#1080#1082
      DisplayWidth = 25
      FieldName = 'ABON_NAME'
      Size = 92
    end
    object dsm_DogovorsMETER_EXIST: TStringField
      DisplayLabel = #1053#1072#1083#1080#1095#1080#1077' '#1089#1095#1077#1090#1095#1080#1082#1072
      DisplayWidth = 15
      FieldName = 'METER_EXIST'
      Size = 11
    end
    object dsm_DogovorsACCPOINT_ID: TIntegerField
      DisplayLabel = #1048#1044' '#1058#1059
      FieldName = 'ACCPOINT_ID'
    end
  end
  object dsm_Append: TMemTableEh
    Params = <>
    Left = 128
    Top = 160
    object dsm_AppendRACCPOINT_ID: TIntegerField
      DisplayLabel = #1048#1044' '#1058#1059
      FieldName = 'RACCPOINT_ID'
    end
    object dsm_AppendRMESSAGE: TStringField
      DisplayLabel = #1057#1086#1086#1073#1097#1077#1085#1080#1077' '#1086#1073' '#1086#1096#1080#1073#1082#1077
      DisplayWidth = 60
      FieldName = 'RMESSAGE'
      Size = 120
    end
  end
  object XLSExportFile: TXLSExportFile
    Left = 240
    Top = 93
  end
  object XLSExportDBGridEh: TXLSExportDBGridEh
    XLSExportFile = XLSExportFile
    DBGridEh = dbgAppendLog
    Options = [eoptVisibleOnly]
    Left = 272
    Top = 93
  end
  object SaveXLSDialog: TSaveDialog
    DefaultExt = 'xls'
    Filter = #1060#1072#1081#1083#1099' Excel (*.xls)|*.xls'
    Title = #1042#1099#1073#1086#1088' '#1092#1072#1081#1083#1072' '#1076#1083#1103' '#1074#1099#1075#1088#1091#1079#1082#1080' '#1076#1072#1085#1085#1099#1093
    Left = 240
    Top = 125
  end
  object pmAppend: TPopupMenu
    Images = MAIN.ImageList
    Left = 272
    Top = 125
    object N1: TMenuItem
      Caption = #1042#1099#1075#1088#1091#1079#1080#1090#1100' '#1074' '#1092#1072#1081#1083
      Hint = #1042#1099#1075#1088#1091#1079#1080#1090#1100' '#1089#1087#1080#1089#1086#1082' '#1086#1096#1080#1073#1086#1082' '#1074' Excel'
      ImageIndex = 7
      OnClick = N1Click
    end
  end
  object ds_Append: TpFIBDataSet
    SelectSQL.Strings = (
      'SELECT'
      '    RACCPOINT_ID,'
      '    RMESSAGE'
      'FROM'
      '    PROC_TU2TU(:PACCPOINT_ID,'
      '    :PACCPOINT_LIST,'
      '    :PDELIMITER,'
      '    :pdate,'
      '    1) ')
    Transaction = AppendTrans
    Database = MAINDM.pMainDatabase
    Left = 62
    Top = 160
    object ds_AppendRACCPOINT_ID: TFIBIntegerField
      FieldName = 'RACCPOINT_ID'
    end
    object ds_AppendRMESSAGE: TFIBStringField
      FieldName = 'RMESSAGE'
      Size = 120
      EmptyStrToNull = True
    end
  end
  object AppendTrans: TpFIBTransaction
    DefaultDatabase = MAINDM.pMainDatabase
    TimeoutAction = TARollback
    Left = 64
    Top = 196
  end
end
